﻿using System;
using System.Configuration.Provider;

namespace Altairis.MailToolkit.Transport {

    public class TransportProviderCollection : ProviderCollection {

        /// <summary>
        /// Adds a provider to the collection.
        /// </summary>
        /// <param name="provider">The provider to be added.</param>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
        ///   </PermissionSet>
        /// <exception cref="System.ArgumentNullException">provider</exception>
        /// <exception cref="System.ArgumentException">The provider parameter must be of type TransportProvider.</exception>
        public override void Add(ProviderBase provider) {
            if (provider == null) throw new ArgumentNullException("provider");
            if (!(provider is TransportProvider)) throw new ArgumentException("The provider parameter must be of type TransportProvider.");
            base.Add(provider);
        }

        /// <summary>
        /// Gets the provider with the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        new public TransportProvider this[string name] {
            get { return (TransportProvider)base[name]; }
        }
    }
}